home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dist / cosmocreate.idb / usr / lib / CosmoCreate / apps / showtogif.z / showtogif
Encoding:
Text File  |  1998-05-07  |  2.5 KB  |  115 lines

  1. #!/bin/sh
  2.  
  3. # debugging output
  4. # set -x
  5.  
  6. # NOTES:
  7. # depends on Habaerli tools and either ghostscript or psrip 
  8.  
  9. # global variables used in the script
  10. progname="showtogif"
  11. usage="Usage: $progname infile outfile"
  12.  
  13. execdir="/usr/lib/CosmoCreate/apps/"
  14.  
  15. showcase=/usr/sbin/showcase
  16. psrip=/usr/lib/print/psrip
  17. psprolog=/usr/lib/print/data/PSRIPprolog
  18. gs1=/usr/bin/X11/gs
  19. gs2=/usr/freeware/bin/gs
  20.  
  21. tmpdir="/tmp/"
  22. fileprefix=".s2g"
  23. prefix="$tmpdir$fileprefix"
  24.  
  25. starterr="xconfirm -header showtogif -t Error:"
  26. enderr="-icon error -B Ok"
  27.  
  28. infile=$1
  29. outfile=$2
  30.  
  31. # make up a unique name (unique enough)
  32. tmpfile=`date +%j%H%M%S`$$
  33.  
  34. # make sure there are exactly 2 arguments 
  35. if [ $# -ne 2 ]; then 
  36.   $starterr -t "Wrong number of arguments." \
  37.             -t "$usage" \
  38.   $enderr
  39.   exit 1 
  40. fi
  41.  
  42. # make sure input file is readable 
  43. if [ ! -r $infile ]; then
  44.   $starterr -t "Input file unreadable." \
  45.   $enderr
  46.   exit 1
  47. fi
  48.  
  49. # make sure output file is writable
  50. touch $outfile
  51. if [ ! -w $outfile ]; then
  52.   $starterr -t "Output file unwritable." \
  53.   $enderr
  54.   exit 1
  55. fi
  56.  
  57. # make sure showcase exists
  58. if [ ! -x $showcase ]; then
  59.   $starterr -t "Showcase not found." \
  60.   $enderr
  61.   exit 1
  62. fi
  63.  
  64. # make sure gs or psrip exists
  65. if [ -x $psrip -a -r $psprolog ]; then
  66.   psrip=1
  67. else 
  68.   if [ -x $gs1 ]; then
  69.     psrip=0
  70.     gs=$gs1
  71.   elif [ -x $gs2 ]; then
  72.     psrip=0
  73.     gs=$gs2
  74.   else
  75.     $starterr -t "Didn't find Ghostscript" \
  76.               -t "or Impressario psrip." \
  77.               -t "One of these must be" \
  78.               -t "installed to convert from" \
  79.               -t "Showcase to GIF." \
  80.     $enderr
  81.     exit 1
  82.   fi
  83. fi 
  84.  
  85. # convert from showcase to postscript
  86. showcase -p $infile > $prefix.$tmpfile.ps 
  87.   
  88. # convert from postscript to encapsulated postscript
  89. ${execdir}pstoeps $prefix.$tmpfile.ps $prefix.$tmpfile
  90.  
  91. # stop showcase from scaling and rotating the page, and fix bbox
  92. ${execdir}fixshow $prefix.$tmpfile.ps $prefix.${tmpfile}0001.eps $prefix.${tmpfile}.eps
  93.  
  94. # convert from encapsulated postscript to rgba
  95. if [ $psrip -eq 1 ]; then
  96.   ${execdir}fromeps $prefix.${tmpfile}.eps $prefix.$tmpfile.rgba -a
  97. else
  98.   ${execdir}epstorgba $prefix.${tmpfile}.eps $prefix.$tmpfile.rgba $gs -a
  99. fi
  100.  
  101. # convert from rgba to rgb
  102. ${execdir}trans128 $prefix.$tmpfile.rgba $prefix.$tmpfile.rgb
  103.  
  104. # crop the transparent region as small as possible
  105. ${execdir}cropimg128 $prefix.$tmpfile.rgb $prefix.$tmpfile.crop.rgb
  106.  
  107. # convert from rgb to gif
  108. ${execdir}togif $prefix.$tmpfile.crop.rgb $outfile -n 256 -x 128 128 128
  109.  
  110. # clean up tmp directory
  111. rm $prefix.${tmpfile}*
  112.  
  113. exit 0
  114.  
  115.